package com.secxiot.consumer.task.feign;

import com.secxiot.common.entity.ResultVo;
import com.secxiot.common.exception.BaseException;
import com.secxiot.provider.task.dto.TaskDto;
import com.secxiot.provider.task.dto.TaskSosDto;
import com.secxiot.provider.task.dto.TaskTransferListDto;
import com.secxiot.provider.task.dto.TaskVisitDto;
import com.secxiot.provider.task.vo.*;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

@FeignClient(value = "provider-task", path = "provider-task")
@Component
public interface TaskClient {

    static String PREFIX = "/tasks";

    @GetMapping(PREFIX)
    TaskHomeVo listUnfinishedByUserIdAndTime(@RequestParam("userId") Long userId, @RequestParam("pageNo") Long pageNo, @RequestParam("pageSize") Long pageSize, @RequestParam("since") Date since, @RequestParam("last") Date last);

    /**
     * 发布任务
     *
     * @param taskDto 任务内容
     * @return
     */
    @PostMapping(PREFIX)
    Long publish(@RequestBody TaskDto taskDto);

    @PostMapping(PREFIX + "/transfer")
    Long publish(TaskTransferListDto taskTransferListDto);

    /**
     * 发布SOS任务
     *
     * @param sosDto SOS任务内容
     * @return 任务id
     */
    @PostMapping(PREFIX + "/sos")
    Long publishSosTask(@RequestBody TaskSosDto sosDto);

    /**
     * 发布出诊任务
     *
     * @param visitDto SOS出诊任务内容
     * @return 任务id
     */
    @PostMapping(PREFIX + "/visit")
    Long publishSosVisit(@RequestBody TaskVisitDto visitDto) throws BaseException;

    /**
     * 获取任务状态信息
     *
     * @param userId 用户id
     * @return 任务状态信息
     */
    @GetMapping(PREFIX + "/sos/status")
    TaskSOSStatusVo getSOSTaskStatusByPatientId(
            @RequestParam(value = "userId", required = true) Long userId,
            @RequestParam(value = "taskId", required = false) Long taskId
    ) throws BaseException;

    @GetMapping(PREFIX + "/sos/diseases")
    List<SosDiseaseVo> getDisease(
            @RequestParam(value = "userId", required = true) Long userId) throws BaseException;

    /**
     * 更新任务状态信息
     *
     * @param userId        用户id
     * @param taskId        任务id
     * @param confirmStatus 状态
     * @return 任务状态信息
     * @throws BaseException
     */
    @PostMapping(PREFIX + "/status")
    TaskStatusUpdateVo updateStatus(
            @RequestParam(value = "userId", required = true) Long userId,
            @RequestParam(value = "taskId", required = true) Long taskId,
            @RequestParam(value = "confirmStatus", required = true) String confirmStatus
    ) throws BaseException;

    /**
     * 获取患者检测数据模版
     *
     * @param deptId 部门id
     * @return 患者检测数据模版列表
     */
    @GetMapping(PREFIX + "/transfer/temp")
    List<TaskTempVo> getTaskTemp(
            @RequestParam(value = "deptId", required = true) Long deptId);

    /**
     * 获取已发布任务
     *
     * @param userId   用户id
     * @param pageNo   页码
     * @param pageSize 条数
     * @return 已发布任务列表
     */
    @GetMapping(PREFIX + "/published")
    List<TaskDisplayVo> getPublishedList(
            @RequestParam(value = "userId", required = true) Long userId,
            @RequestParam(value = "pageNo", required = true) Long pageNo,
            @RequestParam(value = "pageSize", required = true) Long pageSize
    );

    /**
     * 获取我的科室任务
     *
     * @param deptId   部门id
     * @param pageNo   页码
     * @param pageSize 条数
     * @return 我的科室任务列表
     */
    @GetMapping(PREFIX + "/depart")
    List<TaskDisplayVo> getDepartmentList(
            @RequestParam(value = "deptId", required = true) Long deptId,
            @RequestParam(value = "pageNo", required = true) Long pageNo,
            @RequestParam(value = "pageSize", required = true) Long pageSize
    );

    /**
     * 获取按任务类型区分的已发布任务
     *
     * @param userId   用户id
     * @param taskType 任务类型
     * @param pageNo   页码
     * @param pageSize 条数
     * @return 按任务类型区分的已发布任务列表
     */
    @GetMapping(PREFIX + "/released")
    List<TaskDisplayVo> getReleasedList(
            @RequestParam(value = "userId", required = true) Long userId,
            @RequestParam(value = "taskType", required = true) String taskType,
            @RequestParam(value = "pageNo", required = true) Long pageNo,
            @RequestParam(value = "pageSize", required = true) Long pageSize
    );

    /**
     * 获取按任务类型区分的已接收任务
     *
     * @param userId   用户id
     * @param taskType 任务类型
     * @param pageNo   页码
     * @param pageSize 条数
     * @return 已经接收的各种任务类型的列表
     */
    @GetMapping(PREFIX + "/received")
    List<TaskDisplayVo> getReceivedList(
            @RequestParam(value = "userId", required = true) Long userId,
            @RequestParam(value = "taskType", required = true) String taskType,
            @RequestParam(value = "pageNo", required = true) Long pageNo,
            @RequestParam(value = "pageSize", required = true) Long pageSize
    );

    /**
     * 获取任务统计数据
     *
     * @param type     任务类型(1:接收; 2:发布)
     * @param userId   用户ID
     * @param dateTime 时间节点
     * @return
     */
    @GetMapping(PREFIX + "/taskCount")
    TaskCountResultVo getTaskCountResultVo(
            @RequestParam(value = "type", required = true) Integer type,
            @RequestParam(value = "userId", required = true) Long userId,
            @RequestParam(value = "dateTime", required = true) Date dateTime
    );

    /**
     * 获取各种类型的最新一条任务
     *
     * @param userId   用户id
     * @param taskType 任务类型
     * @return 一条该类型的最新任务
     */
    @GetMapping(PREFIX + "/newest")
    TaskDisplayVo getNewestTask(
            @RequestParam(value = "userId", required = true) Long userId,
            @RequestParam(value = "taskType", required = true) String taskType
    );

    /**
     * 首页按类型区分的最新任务、未确认数量
     *
     * @param userId 用户id
     * @return 各种类型的最新任务、未确认数量
     */
    @GetMapping(PREFIX + "/taskHome")
    TaskAndConfirmStatusVo getNewestTaskAndStatus(
            @RequestParam(value = "userId", required = true) Long userId
    );

    /**
     * 搜索任务
     *
     * @param userId     用户id
     * @param searchName 发布人&内容 搜索
     * @param taskType   任务类型
     * @param type       搜索类型(1:接收; 2:发布)
     * @param pageNo     页码
     * @param pageSize   条数
     * @return
     */
    @GetMapping(PREFIX + "/searchTask")
    List<TaskDisplayVo> getSearchTaskList(@RequestParam(value = "userId", required = true) Long userId,
                                          @RequestParam(value = "searchName", required = true) String searchName,
                                          @RequestParam(value = "taskType", required = false) String taskType,
                                          @RequestParam(value = "type", required = true) Integer type,
                                          @RequestParam(value = "pageNo", required = true) Long pageNo,
                                          @RequestParam(value = "pageSize", required = true) Long pageSize);

    /**
     * 获取对应的sos任务ID
     *
     * @param taskId 出诊任务ID
     * @param userId
     * @return
     */
    @GetMapping(PREFIX + "/getSosTaskId")
    Long getSosTaskId(@RequestParam(value = "taskId", required = true) Long taskId,
                      @RequestParam(value = "userId", required = true) Long userId);

    /**
     * sos 上报位置
     *
     * @param taskId
     * @param longitude
     * @param latitude
     */
    @PostMapping(PREFIX + "/sosReportLocation")
    Long sosReportLocation(@RequestParam(value = "userId", required = true) Long userId,
                           @RequestParam(value = "taskId", required = true) Long taskId,
                           @RequestParam(value = "longitude", required = true) BigDecimal longitude,
                           @RequestParam(value = "latitude", required = true) BigDecimal latitude);

    /**
     * 获取医院救护车位置
     *
     * @param hospitalId 医院id
     * @return
     */
    @GetMapping(PREFIX + "/sosAmbulanceLocation")
    List<SosPlatformVo> sosAmbulanceLocation(@RequestParam(value = "hospitalId", required = true) Long hospitalId);

    /**
     * 获取车辆列表
     *
     * @return
     */
    @GetMapping(PREFIX + "/sosAmbulanceList")
    List<RemindAmbulanceVo> getAmbulanceVoList(@RequestParam(value = "hospitalId", required = true) Long hospitalId);

    /**
     * 增加任务车辆记录
     *
     * @return
     */
    @PostMapping(PREFIX + "/saveTaskAmbulance")
    TaskStatusUpdateVo saveTaskAmbulance(@RequestParam(value = "userId", required = true) Long userId,
                                         @RequestParam(value = "taskId", required = true) Long taskId,
                                         @RequestParam(value = "ambulanceId", required = true) Long ambulanceId,
                                         @RequestParam(value = "confirmStatus", required = true) String confirmStatus) throws BaseException;

    /**
     * 发送视频请求
     *
     * @param taskId 任务id
     * @return
     */
    @GetMapping(PREFIX + "/videoStatus")
    int updateReportVideoTask(@RequestParam(value = "taskId", required = true) Long taskId,
                              @RequestParam(value = "userId", required = true) Long userId,
                              @RequestParam(value = "videoStatus", required = true) Integer videoStatus
    );
}
